package acom.dhy.qigsaw2test

import acom.dhy.qigsaw2test.net.ApiUtil
import acom.dhy.qigsaw2test.net.postResult
import acom.dhy.qigsaw2test.qigsaw.startActivityComponent
import com.dhy.annotations.Components
import com.dhy.qigsaw.splash.BaseSplashFragment
import com.dhy.qigsaw.splash.data.TestResult
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers

class SplashFragment : BaseSplashFragment() {
    override fun onAllModuleInstalled() {
        ownerActivity.startActivityComponent(Components.App.MAIN_ACTIVITY)
    }

    override fun onError(msg: String) {
        if (App.AUTO_TEST_MODE) {
            val result = TestResult()
            result.error = msg
            ApiUtil.api.postResult(ownerActivity.applicationContext, result)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({

                }, {
                    it.printStackTrace()
                })
        }
    }
}